
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>用户主页</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <link rel="stylesheet" href="../../static/res/layui/css/layui.css">
  <link rel="stylesheet" href="../../static/res/css/global.css">
</head>
<body style="margin-top: 65px;">

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img src="../../static/res/images/logo.png" alt="layui">
    </a>

    <ul class="layui-nav fly-nav-user">
      <!-- 登入后的状态 -->
        {%if user.id%}
      <li class="layui-nav-item">
        <a class="fly-nav-avatar" href="javascript:;">
          <cite class="layui-hide-xs">{{user.nick_name}}</cite>
          <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：南神认证"></i>
            {%if user.is_vip != 0%}
          <i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{user.is_vip}}</i>
            {%endif%}
          <img src="{{user.avatar_url}}">
        </a>
        <dl class="layui-nav-child">
          <dd><a href="/user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
          <dd><a href="/user/follow"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的关注</a></dd>
          <dd><a href="/user/home?u={{user.id}}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
          <hr style="margin: 5px 0;">
          <dd><a href="/user/logout" style="text-align: center;">退出</a></dd>
        </dl>
      </li>
        {%else%}
         <!-- 未登入的状态 -->
            <li class="layui-nav-item">
                <a class="iconfont icon-touxiang layui-hide-xs" href="/login"></a>
            </li>
            <li class="layui-nav-item">
                <a href="/login">登录</a>
            </li>
            <li class="layui-nav-item">
                <a href="/reg">注册</a>
            </li>
        {%endif%}
    </ul>
  </div>
</div>

<div class="fly-home fly-panel" style="background-image: url();">
    {%if news.items%}
  <img src="{{user.other.avatar_url}}" alt="{{news.items[0].user.nick_name}}">
    {%else%}
      <img src="{{user.avatar_url}}" alt="{{user.nick_name}}">
    {%endif%}
  <i class="iconfont icon-renzheng" title="xx社区认证"></i>
  <h1>

    {{user.other.nick_name}}

      {%if user.other.gender == "MAN" %}
    <i class="iconfont icon-nan"></i>
      {%else%}
    <i class="iconfont icon-nv"></i>
      {%endif%}


      {% if user.other.is_vip != 0%}
    <i class="layui-badge fly-badge-vip">VIP{{user.other.is_vip}}</i>

      {%endif%}
    {%if user.other.is_admin%}
      <span style="color:#c00;">（管理员）</span>
      {%endif%}
  </h1>

  <p class="fly-home-info">
    <i class="iconfont icon-kiss" title="飞吻"></i><span style="color: #FF7200;">{{user.other.award}} 飞吻</span>
    <i class="iconfont icon-shijian"></i><span>{{user.other.create_time}} 加入</span>
  </p>
  {%if user.other.signature%}
  <p class="fly-home-sign">（{{user.other.signature}}）</p>
        {%if user.other.gender == "MAN"%}
        <span>他的粉丝：{{user.other.fs}}</span>&nbsp;&nbsp;&nbsp;
        <span>他的关注：{{user.other.gz}}</span>
        {%else%}
        <span>她的粉丝：{{user.other.fs}}</span>&nbsp;&nbsp;&nbsp;
        <span>她的关注：{{user.other.gz}}</span>
        {%endif%}
    {%elif user.other.gender == "MAN"%}
      <p class="fly-home-sign">他很神秘， 什么都没留下....</p>
        <span>他的粉丝：{{user.other.fs}}</span>&nbsp;&nbsp;&nbsp;
        <span>他的关注：{{user.other.gz}}</span>
    {%elif user.other.gender == "WOMAN"%}
      <p class="fly-home-sign">她很神秘， 什么都没留下....</p>
                <span>她的粉丝：{{user.other.fs}}</span>&nbsp;&nbsp;&nbsp;
        <span>她的关注：{{user.other.gz}}</span>
    {%endif%}
  <div class="fly-sns" data-user="">

      {%if user.other.id != user.id%}
        {%if user.id %}
      {%if user.other not in user.followed.all()%}
    <a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend" onclick="shoc({{user.other.id}})">关注</a>
                       <input type="hidden" id="sc" value="do">
    {%else%}
          <a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend" onclick="shoc({{user.other.id}})">取消关注</a>
                       <input type="hidden" id="sc" value="undo">
      {%endif%}
      {%else%}
          <a href="javascript:;" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend" onclick="shoc({{user.other.id}})">关注</a>
                       <input type="hidden" id="sc" value="do">
      {%endif%}
      {%endif%}
  </div>

</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md6 fly-home-jie">
      <div class="fly-panel">
        <h3 class="fly-panel-title">{{user.other.nick_name}} 最近的发帖({{news.total}})</h3>
        <ul class="jie-row">
        {% for i in news.items%}
          <li>
            <span class="fly-jing">精</span>
            <a href="/detail/{{i.id}}" class="jie-title"> {{i.title}}</a>
            <em class="layui-hide-xs">{{i.clicks}}阅/{{i.comment_num}}答</em>
          </li>
           {% endfor %}
            {% if not user.other.news%}
          <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i style="font-size:14px;">没有发表任何贴子</i></div>
            {%endif%}
        </ul>
      </div>
    </div>
    
    <div class="layui-col-md6 fly-home-da">
      <div class="fly-panel">
        <h3 class="fly-panel-title">{{user.other.nick_name}} 最近的回答({{answer.total}})</h3>
        <ul class="home-jieda">
            {%for i in answer.items%}
          <li>
          <p>

          在<a href="/detail/{{i.news.id}}" target="_blank">{{i.news.title}}</a>中回答：
          </p>
          <div class="home-dacontent">
            {{i.content | safe}}
          </div>
        </li>
        {%endfor%}
        {%if not user.other.comment%}
         <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>没有回答任何问题</span></div>
            {%endif%}
        </ul>
      </div>
    </div>
  </div>
</div>
        <div >
            <div style="border-top: 1px dotted #e2e2e2">
            <div class="laypage-main" style="margin-left:-20%">
                {%if news.page != 1%}
                <a href="/user/home?u={{user.other.id}}&page=1" class="laypage-last" title="首页">首页</a>
                {%endif%}
                {%if news.has_prev%}
                <a href="/user/home?u={{user.other.id}}&page={{news.prev_num}}" class="laypage-prev">上一页</a>
                {%endif%}
                 <span class="laypage-curr">{{news.page}}</span>
                {%if news.page + 1 <= news.pages%}
                <a href="/user/home?u={{user.other.id}}&page={{news.page + 1}}">{{news.page + 1}}</a>
                {%endif%}
                  {%if news.page + 2 <= news.pages%}
                <a href="/user/home?u={{user.other.id}}&page={{news.page + 2}}">{{news.page + 2}}</a>
                {%endif%}
                   {%if news.page + 3 <= news.pages%}
                <a href="/user/home?u={{user.other.id}}&page={{news.page + 3}}">{{news.page + 3}}</a>
                {%endif%}
                  <span>…</span>
                  <a href="/user/home?u={{user.other.id}}&page={{news.pages}}" class="laypage-last" title="尾页">尾页</a>
                {%if news.has_next%}
                 <a href="/user/home?u={{user.other.id}}&page={{news.next_num}}" class="laypage-next">下一页</a>
                {%endif%}
             </div></div></div>


<div class="fly-footer">
  <p><a href="http://fly.layui.com/" target="_blank">Fly社区</a> 2017 &copy; <a href="http://www.layui.com/" target="_blank">layui.com 出品</a></p>
  <p>
    <a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a>
    <a href="http://www.layui.com/template/fly/" target="_blank">获取Fly社区模版</a>
    <a href="http://fly.layui.com/jie/2461/" target="_blank">微信公众号</a>
  </p>
</div>

<script src="../../static/res/layui/layui.js"></script>
<script src="../../static/js/jquery-3.3.1.js"></script>
<script>
    function shoc(e) {
    var zl = document.getElementById("sc").value;
        var params = {
            "zl": zl,
            "follow": e
        };
        $.ajax({
            url: "/user/home",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.errno == "0") {
                   location=location
                }
                else if (resp.errno == "3002"){
                    alert(resp.msg)
                    location.href="http://www.tnan.top/login"
                }
                else {
                    alert(resp.msg)
                }
    }})
    }

layui.cache.page = 'user';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "3.0.0"
  ,base: '../static/res/mods/'
}).extend({
  fly: 'index'
}).use('fly');
</script>

</body>
</html>